package com.zoo.diannaopeijian.mapper;

import com.zoo.diannaopeijian.domain.Stock;
import com.zoo.diannaopeijian.domain.StockExample;
import java.util.List;
import java.util.Map;

import com.zoo.diannaopeijian.domain.Ware;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface StockMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table stock
     *
     * @mbggenerated
     */
    @SelectProvider(type=StockSqlProvider.class, method="countByExample")
    int countByExample(StockExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table stock
     *
     * @mbggenerated
     */
    @DeleteProvider(type=StockSqlProvider.class, method="deleteByExample")
    int deleteByExample(StockExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table stock
     *
     * @mbggenerated
     */
    @Delete({
        "delete from stock",
        "where StockId = #{stockid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer stockid);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table stock
     *
     * @mbggenerated
     */
    @Insert({
        "insert into stock (StockId, WareId, ",
        "WarehouseId, StockNum)",
        "values (#{stockid,jdbcType=INTEGER}, #{wareid,jdbcType=INTEGER}, ",
        "#{warehouseid,jdbcType=INTEGER}, #{stocknum,jdbcType=INTEGER})"
    })
    int insert(Stock record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table stock
     *
     * @mbggenerated
     */
    @InsertProvider(type=StockSqlProvider.class, method="insertSelective")
    int insertSelective(Stock record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table stock
     *
     * @mbggenerated
     */
    @SelectProvider(type=StockSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="StockId", property="stockid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="WareId", property="wareid", jdbcType=JdbcType.INTEGER),
        @Result(column="WarehouseId", property="warehouseid", jdbcType=JdbcType.INTEGER),
        @Result(column="StockNum", property="stocknum", jdbcType=JdbcType.INTEGER)
    })
    List<Stock> selectByExample(StockExample example);

    @SelectProvider(type=StockSqlProvider.class, method="getWareStock")
    @Results({
            @Result(column="StockId", property="stockid", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="ComponentName", property="componentname", jdbcType=JdbcType.VARCHAR),
            @Result(column="WareId", property="wareid", jdbcType=JdbcType.INTEGER),
            @Result(column="WareName", property="warename", jdbcType=JdbcType.VARCHAR),
            @Result(column="Barcode", property="barcode", jdbcType=JdbcType.VARCHAR),
            @Result(column="StockNum", property="stocknum", jdbcType=JdbcType.INTEGER),
            @Result(column="WarehouseName", property="warehousename", jdbcType=JdbcType.VARCHAR),
            @Result(column="WarehouseId", property="warehouseid", jdbcType=JdbcType.VARCHAR),
    })
    List<Map> getWareStock(@Param("componentid") Integer componentid,
                           @Param("componentparameterdetailid") Integer componentparameterdetailid,
                           @Param("warehouseid") Integer warehouseid,
                           @Param("ware") Ware ware);

    @SelectProvider(type = StockSqlProvider.class, method = "getFuzzyWareStock")
    @Results({
            @Result(column="StockId", property="stockid", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="ComponentName", property="componentname", jdbcType=JdbcType.VARCHAR),
            @Result(column="WareId", property="wareid", jdbcType=JdbcType.INTEGER),
            @Result(column="WareName", property="warename", jdbcType=JdbcType.VARCHAR),
            @Result(column="Barcode", property="barcode", jdbcType=JdbcType.VARCHAR),
            @Result(column="StockNum", property="stocknum", jdbcType=JdbcType.INTEGER),
            @Result(column="WarehouseName", property="warehousename", jdbcType=JdbcType.VARCHAR),
            @Result(column="WarehouseId", property="warehouseid", jdbcType=JdbcType.VARCHAR),
    })
    List<Map> getFuzzyWareStock(@Param("componentid") Integer componentid,
                                @Param("componentparameterdetailid") Integer componentparameterdetailid,
                                @Param("warehouseid") Integer warehouseid,
                                @Param("ware") Ware ware);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table stock
     *
     * @mbggenerated
     */
    @Select({
        "select",
        "StockId, WareId, WarehouseId, StockNum",
        "from stock",
        "where StockId = #{stockid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="StockId", property="stockid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="WareId", property="wareid", jdbcType=JdbcType.INTEGER),
        @Result(column="WarehouseId", property="warehouseid", jdbcType=JdbcType.INTEGER),
        @Result(column="StockNum", property="stocknum", jdbcType=JdbcType.INTEGER)
    })
    Stock selectByPrimaryKey(Integer stockid);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table stock
     *
     * @mbggenerated
     */
    @UpdateProvider(type=StockSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Stock record, @Param("example") StockExample example);

    @Update({
        "update stock set StockNum = StockNum + #{value,jdbcType=INTEGER} where StockId = #{stockid,jdbcType=INTEGER}"
    })
    int updateStockNum(@Param("value") Integer value, @Param("stockid") Integer stockid);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table stock
     *
     * @mbggenerated
     */
    @UpdateProvider(type=StockSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Stock record, @Param("example") StockExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table stock
     *
     * @mbggenerated
     */
    @UpdateProvider(type=StockSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Stock record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table stock
     *
     * @mbggenerated
     */
    @Update({
        "update stock",
        "set WareId = #{wareid,jdbcType=INTEGER},",
          "WarehouseId = #{warehouseid,jdbcType=INTEGER},",
          "StockNum = #{stocknum,jdbcType=INTEGER}",
        "where StockId = #{stockid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Stock record);
}